package utils

import (
	"github.com/zeromicro/go-zero/core/logx"
	"io/ioutil"
	"net/http"
	"strings"
)

func PostRequest(url string, byte []byte) ([]byte, error) {
	logx.Infof("请求参数 ---------------------------------> %s", string(byte))
	reqBody := strings.NewReader(string(byte))
	request, err := http.NewRequest("POST", url, reqBody) // 注意请求方法必须大写
	if err != nil {
		return nil, err
	}
	request.Header.Add("Content-Type", "application/json;charset=UTF-8")
	client := &http.Client{}
	response, err := client.Do(request)
	if err != nil {
		return nil, err
	}
	body, err := ioutil.ReadAll(response.Body)
	logx.Infof("响应结果 --------------------------------->%s", string(body))
	return body, err
}
